import type { AxiosResponse } from 'axios'
import request from '@/utils/request'

const serviceName = import.meta.env.VITE_APP_SREVICE_NAME_CITY_MANAGEMENT

// 指标相关接口
class QuotaServe {
  /**
   * 获取行业列表
   * @param params { division, id }
   */
  getIndustryList<T = any>(params = {}): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/cgjybzIndustry/getIndustryById`,
      method: 'get',
      params
    })
  }

  /**
   * 获取行业指标列表
   * @param params {type}
   */
  getQuotaList<T = any>(params = {}): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/cgjybzIndustry/getDetailsByType`,
      method: 'get',
      params
    })
  }

  /**
   * 获取收藏行业指标列表
   * @param params {type}
   */
  getQuotaFavList<T = any>(): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/cgjybzIndustry/getCollectById`,
      method: 'get'
    })
  }

  /**
   * 搜索
   * @param params {type}
   */
  selRelation<T = any>(params = {}): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/cgjybzIndustry/selRelation`,
      method: 'get',
      params
    })
  }

  /**
   * 搜索
   * @param params {type}
   */
  commitFeedback<T = any>(params = {}): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/cgjybzMine/commitFeedback`,
      method: 'get',
      params
    })
  }

  /**
   * 修改密码
   * @param params {type}
   */
  changePassword<T = any>(params = {}): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/sys/user/password`,
      method: 'put',
      data: params
    })
  }

  /**
   * 搜索下拉框
   * @param params {type}
   */
  selPage<T = any>(): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/cgjybzIndustry/selPage`,
      method: 'get'
    })
  }

  /**
   * 指标详情
   * @param params { typeId }
   * @returns
   */
  getQuotaDetail<T = any>(params = {}): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/cgjybzIndustry/getRightDetailsByTypeId`,
      method: 'get',
      params
    })
  }

  /**
   * 首页异常指标信息
   * @param type string eg: road_clean
   * @returns
   */
  getAbnormalInfo<T = any>(type: string): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/cgjybzIndustryAnomalyIndex/getAbnormalIndicatorsOnHomepage?type=${type}`,
      method: 'get'
    })
  }
  /**
   * 国家重点管控资源
   */
  getPricePrediction<T = any>(data: { isCollect: string | number }): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/event/getPricePrediction`,
      method: 'post',
      data
    })
  }
  /**
   * 城市比较
   */
  getCitiesCompare<T = any>(quotaId: string): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/cgjybzIndustry/getCitiesCompare?quotaId=${quotaId}`,
      method: 'get'
    })
  }
}

export default new QuotaServe()
